package com.framework.sec.util.filter;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;

public class SecSimpleUrlLogoutSuccessHandler extends
		SimpleUrlLogoutSuccessHandler {
	private String logoutUrl;
	public void onLogoutSuccess(HttpServletRequest request,
			HttpServletResponse response,
			Authentication authentication) throws IOException,
			javax.servlet.ServletException {
		Object principal = null;
		if(authentication!=null){
			principal = authentication.getPrincipal();
		}
		System.out.println("logout:"+principal);
		
		request.getRequestDispatcher(logoutUrl).forward(request, response);
	}
    	
	public void setLogoutUrl(String logoutUrl) {
		this.logoutUrl = logoutUrl;
	}
	public String getLogoutUrl() {
		return logoutUrl;
	}
}